#include "ThreadPool.h"
#include "api.h"
#include <stdlib.h>
#include <string.h>


int main(int argc, char **argv)
{
    char **file_path = (char **)malloc(sizeof(char *) * 105);
    int file_cnt = 0, thread_cnt = 0, pthread_flag = 0;
    char *job_flag = "-j";

    for (int i = 1; i < argc; ++i)
    {
        if (strcmp(argv[i], job_flag) == 0)
        {
            pthread_flag = 1;
            ++i;
            thread_cnt = atoi(argv[i]);
        }
        else
        {
            file_path[file_cnt] = argv[i];
            ++file_cnt;
        }
    }

    if (pthread_flag == 1)
    {
        multi_file_multi_thread_RLEencode(file_cnt, file_path, thread_cnt);
    }
    else if (pthread_flag == 0)
    {
        multi_file_single_thread_RLEencode(file_cnt, file_path);
    }
    free(file_path);

    return 0;
}
